package densetsu.model.map;

import java.io.FileNotFoundException;

import densetsu.model.map.tiles.Tile;

/**
 * Implementation of the map interface. Will represent the game map.
 * 
 * @author Koen
 * 
 */
public class GameMap implements GridMap {

	public static final int SIZE = 10;
	private Tile[][] tiles;
	private Maps levels;
	private int currentLevel;

	public GameMap ( ) {
		levels = new Maps ( );
		currentLevel = 1;
		try {
			tiles = MapLoader.getMap ( levels.getMapFileName ( currentLevel ) );
		} catch ( FileNotFoundException e ) {
			e.printStackTrace ( );
		}
	}

	@Override
	public Tile getTileAt ( int x, int y ) {
		return tiles[x % SIZE][y % SIZE];
	}

	@Override
	public void setTileAt ( Tile tile, int x, int y ) {
		tiles[x][y] = tile;
	}

	@Override
	public void loadNewMap ( int n ) {
		try {
			tiles = MapLoader.getMap ( levels.getMapFileName ( n ) );
		} catch ( FileNotFoundException e ) {
			e.printStackTrace ( );
		}
	}

}
